//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Common
//  File name:	IFormsService.cs
//  Developer:	Solomatov Igor
//  Created:	15.04.2012
// 
//  -------------------- iSharePoint -------------------- //

using System.Collections.Generic;

namespace Smart.Common.Forms
{
	/// <summary>
	/// Forms service
	/// </summary>
	public interface IFormsService
	{
		/// <summary>
		/// Forms context
		/// </summary>
		FormsContext Ctx { get; set; }

		/// <summary>
		/// Forms source (lazy)
		/// </summary>
		FormsSource Source { get; set; }

		/// <summary>
		/// Forms formatter (lazy)
		/// </summary>
		FormsFormatter Formatter { get; set; }

		/// <summary>
		/// Forms builder (lazy)
		/// </summary>
		FormsBuilder Builder { get; set; }

		/// <summary>
		/// Creates forms context
		/// </summary>
		void InitContext(string serviceName);

		/// <summary>
		/// Init service (also fills lazy properties)
		/// </summary>
		void InitService();

		/// <summary>
		/// Create forms source
		/// </summary>
		FormsSource CreateSource();

		/// <summary>
		/// Create forms formatter
		/// </summary>
		FormsFormatter CreateFormatter();

		/// <summary>
		/// Create forms builder
		/// </summary>
		FormsBuilder CreateBuilder();

		/// <summary>
		/// Build form for <paramref name="entity"/> in <paramref name="container"/>
		/// </summary>
		bool BuildForm(IFormEntity entity, IFormContainer container, MetaFormMode mode, IDictionary<string, object> values);

		/// <summary>
		/// Save form values to entity
		/// </summary>
		bool SaveForm();

		/// <summary>
		/// Perform action from rules on form
		/// </summary>
		bool PerformAction(string actionName, string[] actionArgs, out bool handled);

		/// <summary>
		/// Execute rule condition function
		/// </summary>
		bool ExecuteFunction(string functionName, string[] functionArgs, out bool handled);
	}
}